
import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:jubobao/services/JuBoConfig.dart';
import 'package:jubobao/services/JuBoHttpRequest.dart';

import 'approval/model/JuBoApprovalListModel.dart';
import 'approval/model/JuBoApprovalModel.dart';

class JuBoApprovalServices
{
  static Future<List> approvalRequest () async {

    final params = {
                    'id':'0',
                    'userId':'676',
                    'tier':'2',
                    };

  final result =  await JuBoHttpNativeRequest.nativeRequest(
                      'ServiceInterface/JuboBao/AppFunctionRight.asmx/GetFunctionList',
                       params: params
                  );

    final resultJson = result['d']['ReList'];
    List results = [];
    for(var json in resultJson){
      results.add(JuBoApprovalClassModel.fromJson(json));
    }
    return results;
  }


  static Future<List> approvalListRequest ({
        @required int approvalOver,
        @required int pageIndex,

  }) async {

    final params = {
              'model' : {
                  "UserID": "676",
                  "ApprovalOver": approvalOver,
                  "InfoType": 3,
                  "pageSize": pageIndex
              }
            };

    final result =  await JuBoHttpNativeRequest.nativeRequest(
        'ServiceInterface/JuboBao/ApprovalApply.asmx/QueryApprovalDataApi',
        params: params
    );
    final resultJson = result['d']['ReList'];
    List results = [];
    for(var json in resultJson){
      results.add(JuBoApprovalListModel.fromJson(json));
    }
    return results;
  }

}